<template>
	<view class="page-index">
		<view class="top-box">
			<view :class="[tabsIndex==index?'top-item-yes':'top-item-no']" v-for="(item,index) in tabsList" :key="index"
				@click="tabChange(item,index)">
				{{item.name}}
			</view>

		</view>
		<view class="complaint-box">
			<view class="complaint-item" v-for="(item,index) in list" :key="index" @click="getInfo(item)">
				<view class="top-item">
					<image :src="item.tx" class="top-image"></image>
					<view class="top-right">
						<view class="time">
							{{item.cjTime}}
						</view>
						<image src="/static/index/已完成.png" mode="" style="width: 169rpx;height: 47rpx;"
							v-if="item.zt==1"></image>
						<image src="/static/index/处理中.png" mode="" style="width: 169rpx;height: 47rpx;"
							v-if="item.zt==0"></image>
					</view>
				</view>
				<view class="center-item">
					{{item.name}}
				</view>
				<view class="bottom-item">
					{{item.text}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import * as index from '@/api/index.js'
	export default {
		data() {
			return {
				list: [],
				form: {
					zt: '',
					uId: uni.getStorageSync('userinfo').userId, //用户id
				},
				tabsIndex: 0,
				tabsList: [{
						name: '全部投诉'
					},
					{
						name: '未回复投诉'
					},
					{
						name: '已完成投诉'
					}
				]
			}
		},
		onLoad(params) {
			if (params.index) {
				this.tabsIndex = params.index
				this.form.zt = params.index == 0 ? '' : params.index - 1
				this.getList()
			} else {
				this.getList()
			}
			// 获取投诉列表
			// this.getList()
		},
		methods: {
			getList() {
				this.loading = false
				index.tsjyList(this.form).then(res => {
					this.loading = true
					this.list.push(...res.page)
				})
			},
			tabChange(item, index) {
				if (this.loading && index != 0) {
					this.tabsIndex = index
					this.form.zt = index - 1
					this.list = []
					this.getList()
				} else if (this.loading && index == 0) {
					this.tabsIndex = index
					this.form.zt = ''
					this.list = []
					this.getList()
				}

			},
			getInfo(item){
				this.$tools.navigate('/pages/user/complaintInfo/index?id='+item.id)
			}
		}
	}
</script>

<style scoped lang="scss">
	.page-index {
		position: relative;

		.top-box {
			position: sticky;
			top: 0;
			left: 0;
			width: 690rpx;
			padding-left: 30rpx;
			padding-right: 30rpx;
			padding-top: 30rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			background-color: #ffffff;

			.top-item-no {
				padding-bottom: 30rpx;
				font-size: 30rpx;
				font-family: Microsoft YaHei;
				font-weight: 400;
				color: #3A3A3A;
			}

			.top-item-yes {
				padding-bottom: 30rpx;
				font-size: 30rpx;
				font-family: Microsoft YaHei;
				font-weight: 400;
				color: #4088D3;
				border-bottom: 2px solid #4088D3;
				;
			}
		}

		.complaint-box {

			.complaint-item {
				padding: 28rpx 32rpx;
				background: #fff;
				margin-bottom: 8rpx;

				.top-item {
					display: flex;

					.top-image {
						width: 73rpx;
						height: 73rpx;
						border-radius: 50%;
						flex-shrink: 0;
						margin-right: 16rpx;
					}

					.top-right {
						width: 100%;
						display: flex;
						justify-content: space-between;
						align-items: flex-end;

						.time {
							font-size: 18rpx;
						}
					}
				}

				.center-item {
					font-size: 34rpx;
					margin: 36rpx 0;
				}

				.bottom-item {
					overflow: hidden;
					/* 三行显示省略号 */
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					font-size: 29rpx;
					text-align: justify;
				}
			}
		}
	}
</style>